<template>
  <view>
    <button @click="setStorage">存缓存</button>
    <button @click="getStorage">取缓存</button>
    <button @click="remove">删abc缓存</button>
    <button @click="clear">删缓存</button>
  </view>
</template>

<script>
  export default {
    data() {
      return {}
    },
    methods: {
      setStorage() {
        //存同步缓存
        uni.setStorageSync('abc', 'nihao')
        //存异步缓存
        uni.setStorage({
          key: 'abc123',
          data: 'this is setstorage',
          success() {
            console.log('成功')
          }
        })
      },
      // 取缓存
      getStorage() {
        // 同步
        uni.getStorageSync('abc')
        // 异步
        uni.getStorage({
          key: 'abc123',
          success(res) {
            console.log(res.data)
          }
        })
      },
      remove(){
        uni.removeStorageSync('abc')
        //清除abc123
        uni.removeStorage({
          key:'abc123',
          success(res){
            console.log('成功');
          }
        })
      },
      clear(){
        uni.clearStorage()
      }
    }
  }
</script>

<style>

</style>
